$(function(){
	ajax();
	$("#search-button").click(function(){
    	var options=$("#subject-select option:selected");
    	$.ajax({
     		url : "/blackhouse/subject",
     		type : "post",
     		data:{"sea1":$("#search-value").val(),"code":1},
     		dataType : "json",
     		success : function(e) {
     			var html="<table class='table table-bordered' id='subject-table'>"
     			 	html+="<tr>"
     				html+="<th>课程编号</th>"
     				html+="<th>课程名字</th>"
     				html+="<th>科任老师</th>"
     				html+="<th>年级编号</th>"
     				html+="</tr>";
     			var select = "";
     			var i=0;
     			for( i = 0;i<e.length;i++){
     				html+="<tr>";
     				html+="<td>"+e[i].subjectcode+"</td>";
     				html+="<td>"+e[i].subjectname+"</td>";
     				html+="<td>"+e[i].teacher+"</td>";
     				html+="<td>"+e[i].gradeName+"</td>";
     				html+="</tr>";
     			};
     			html+="</table>"
     			$("#subject-table-box").html(html);   
     			$("#subject-hint").html("共"+i+"条记录")
     		}
    	});
    })
})
function ajax(){
 	$.ajax({
 		url : "/blackhouse/subject",
 		type : "post",
 		data:{"code":"1"},
 		dataType : "json",
 		success : function(e) {
 			var html="<table class='table table-bordered' id='subject-table'>"
 				html+= "<tr>"
 				html+="<th>课程编号</th>"
 				html+="<th>课程名字</th>"
 				html+="<th>科任老师</th>"
 				html+="<th>年级编号</th>"
 				html+="</tr>";
 			var i=0;
 			for( i = 0;i<e.length;i++){
 				html+="<tr>";
 				html+="<td>"+e[i].subjectcode+"</td>";
 				html+="<td>"+e[i].subjectname+"</td>";
 				html+="<td>"+e[i].teacher+"</td>";
 				html+="<td>"+e[i].gradeName+"</td>";
 				html+="</tr>";
 							
 			};
 			html+="</table>"
 			$("#subject-table-box").html(html);   
 			$("#subject-hint").html("共"+i+"条记录")
  		}
 	})
}
